package com.rt.java.util;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadLocalDemo {
    static ThreadLocal<Integer> threadLocal = new ThreadLocal<>();

    public static void main(String[] args) {
        ExecutorService threadPool = Executors.newFixedThreadPool(5);
        for (int i = 1; i < 6; i++) {
            final int value = i;
            threadPool.execute(() -> {
                threadLocal.set(value);
                threadLocal.get(); // 1
                threadLocal.remove();
                threadLocal.get(); // null
            });

        }
    }
}
